package cn.com.dashihui.api.Queue;

import java.util.concurrent.LinkedBlockingQueue;
/**
 * 单例对象
 * @author Administrator
 *
 */
public class SingleQueue {
	
	
	private static LinkedBlockingQueue<String> singleQueue ;
	private static boolean flag = false;
	
	private SingleQueue (){
		
		synchronized (SingleQueue.class) {
			if (flag) {
				throw new RuntimeException("禁止违规创建单例对象");
			} else {
				flag = !flag;
			}
		}
	}
	
	public static LinkedBlockingQueue<String> getInstance() {
		if ( singleQueue == null ) {
			synchronized ( SingleQueue.class ) {
				if ( singleQueue == null ) {
					singleQueue = new LinkedBlockingQueue<String>();
				}
			}
		}
		return singleQueue;
	}
}
